<?php
class MyActiveRecord extends CActiveRecord {
	private static $mydb = null;

	protected static function getMyDbConnection()
	{
		if (self::$mydb !== null)
			return self::$mydb;
		else
		{
			self::$mydb = Yii::app()->mydb;
			if (self::$mydb instanceof CDbConnection)
			{
				self::$mydb->setActive(true);
				return self::$mydb;
			}
			else
				throw new CDbException(Yii::t('yii','Active Record requires a "db" CDbConnection application component.'));
		}
	}
	
	public function getDbConnection()
	{
		return self::getMyDbConnection();
	}
}
